package l.l.w.practice.校招全国统一模拟笔试第五场编程题集合2017年.彩色瓷砖;

import java.util.Scanner;

/**
 * Created by llw on 2017/10/12.
 */
public class 彩色瓷砖 {

    char[] color = {'R','G','B','Y'};
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int result = new 彩色瓷砖().modify(str);
        System.out.println(result);
    }

    public int modify(String str1) {
        int count = 0;
        StringBuffer str = new StringBuffer(str1);
        for(int i =0; i < str.length() -1; ++i){
            if(str.charAt(i) == str.charAt(i+1)){
                if(i+2 < str.length()){
                    for(int j =0; j < color.length; ++j){
                        if(str.charAt(i) != color[j] && str.charAt(i+2) != color[j]){
//                            str.replace(i+1,i+2,new String(new char[]{color[j]}));
//                            ++i;
                            str.replace(++i,i+1,new String(new char[]{color[j]}));
                            count++;
                            break;
                        }
                    }
                }else{
                    for(int j =0; j < color.length; ++j){
                        if(str.charAt(i) != color[j] ){
                            str.replace(i+1,i+2,new String(new char[]{color[j]}));
                            ++i;
                            count++;
                            break;
                        }
                    }
                }
            }
        }
        return  count;
    }
}
